package com.choudou5.solr.utils;

import com.choudou5.solr.service.ServiceHelper;
import com.choudou5.solr.service.biz.BizDataService;
import com.choudou5.solr.util.JsonUtil;
import com.choudou5.solr.util.StrUtil;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @name 业务数据工具类
 * @author choudou5
 * @date 2018-08-15
 */
public class BizDataUtil {

    private static BizDataService bizDataService = ServiceHelper.singleton(BizDataService.class);

    public static String getBizData(String bizKey){
        String bizData = bizDataService.findOneColumn("json_content", " biz_key = '" + bizKey + "'");
        return bizData;
    }

    public static Map getBizJsonDataMap(String bizKey){
        String bizData = bizDataService.findOneColumn("json_content", " biz_key = '" + bizKey + "'");
        if(StrUtil.isNotBlank(bizData)){
            return JsonUtil.toJavaObj(bizData, LinkedHashMap.class);
        }
        return new HashMap(0);
    }

}
